{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "对x求偏导:\n",
      "2*x\n",
      "对y求偏导\n",
      "4*y\n"
     ]
    }
   ],
   "source": [
    "from sympy import symbols, diff\n",
    "\n",
    "#自己定义一个多元函数\n",
    "def function_2(x,y):\n",
    "    return x**2 + 2*y**2\n",
    "\n",
    "\n",
    "#先将所求变量（x，y）符号化。\n",
    "x, y = symbols('x y', real=True)\n",
    "\n",
    "\n",
    "print(\"对x求偏导:\")\n",
    "print(diff(function_2(x, y), x))\n",
    "print(\"对y求偏导:\")\n",
    "print(diff(function_2(x,y),y))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "I'm a teapot\n"
     ]
    }
   ],
   "source": [
    "def http_error(status):\n",
    "    match status:\n",
    "        case 400:\n",
    "            return \"Bad request\"\n",
    "        case 404:\n",
    "            return \"Not found\"\n",
    "        case 418:\n",
    "            return \"I'm a teapot\"\n",
    "        case _:\n",
    "            return \"Something's wrong with the internet\"\n",
    "\n",
    "print(http_error(418))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.3"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
